using Core.Contracts.Interfaces;

namespace Core.Features
{
    using System;
    using Base;
    using Contracts.Enums;
    using Resources;


    public sealed class IndustrialCpuUsage<T> : FeatureBase<object>
    {
        public IndustrialCpuUsage() { }

        public IndustrialCpuUsage(T value)
            : base(value) { }
        /// <summary>
        /// Obtains the feature name
        /// </summary>
        public override string Name
        {
            get { return "Cpu usage"; }
        }
        /// <summary>
        /// Obtains the feature group
        /// </summary>
        public override FeatureGroupsEnum FeatureGroup { get { return FeatureGroupsEnum.Engine; } }
        /// <summary>
        /// Obtains the feature type
        /// </summary>
        public override FeaturesEnum FeatureType { get { return FeaturesEnum.IndustrialCpuUsage; } }
        /// <summary>
        /// Obtains or defines the feature unit
        /// </summary>
        public override string Unit { get { return Traduction.label_unit_TF; } }

        public override void SetModifiedValue(Contracts.Interfaces.IAgent agent, Contracts.Interfaces.IRobot robot)
        {
            if (agent == null || robot == null) return;

            double extensionBonus = agent.Extensions.SumModifiersValues(FeatureTypesEnum.Module, this.FeatureType);

            double RobotBonus = robot.Modifiers.SumModifiersValues(agent.Extensions, FeatureTypesEnum.Module, this.FeatureType);

            double temp = (double)Value * (1 + (extensionBonus + RobotBonus));

            ModifiedValue = IsRounded
                                ? Math.Round(temp, 0, MidpointRounding.AwayFromZero)
                                : Math.Round(temp, 2);
        }
    }
}